package com.imdroid.logic;

import java.util.Collection;

import com.imdroid.modal.Contact;

import net.orange.architecture.db.Condition;
import net.orange.architecture.db.Conditions;
import net.orange.architecture.db.Operator;
import net.orange.architecture.process.BaseProcess;

/**
 * The contact process
 * 
 */
public class ContactProcess extends BaseProcess implements IContactProcess {
	/*
	 * (non-Javadoc)
	 * 
	 * @see com.imdroid.logic.IContactProcess#findCotanct(int, java.lang.String)
	 */
	public Contact findCotanct(int user_id, String phone_number)
			throws Exception {
		Conditions cnds = new Conditions();
		cnds.add(new Condition("user_id", new Operator(Operator.EQUAL), user_id));
		cnds.add(new Condition("phone_number", new Operator(Operator.EQUAL),
				phone_number));
		return (Contact) dao.find(cnds);
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see com.imdroid.logic.IContactProcess#getCotanct(int)
	 */
	public Collection getCotanct(int user_id) throws Exception {
		Conditions cnds = new Conditions();
		cnds.add(new Condition("user_id", new Operator(Operator.EQUAL), user_id));
		return dao.list(cnds);
	}
}
